package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    ShoppingCart findUidAndDidOrSid(ShoppingCart shoppingCart);

    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void save(ShoppingCart shoppingCart);

    @Update("UPDATE shopping_cart SET number=#{number} WHERE id= #{id}")
    void update(ShoppingCart dbshoppingCart);

    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> findByUserId(Long userId);

    @Delete("DELETE FROM shopping_cart WHERE user_id = #{userId};")
    void clean(Long userId);
}
